const mongoose = require('ty-js-model');

exports.BranchItem = class BranchItem {
    constructor(branchName) {
        this.name = branchName
        this.profile = {
            description: '',
            website: '',
        }
        this.lastest_commit_id = ''
        this.commit_set = [] // 所有commit集合
        // 这个用来记录所有文件的信息
        // key是文件的hash值 value是文件的信息
        this.file_commit_hashmap = {}
    }
}

exports.RepoItem = class RepoItem {
    constructor(name, type, comment, updated_time, is_overviews, relative_time) {
        this.name = name // 不要.git后缀
        this.type = type
        this.comment = comment // 仓库描述，简介
        this.updated_time = updated_time // 统计所有分支最后修改时间
        this.relative_time = relative_time // 统计所有分支最后修改的相对时间
        this.is_overviews = is_overviews // 是否展示在overview

        // key 分支名称，
        /** @type { Object<string, BranchItem> } */
        this.branch = {}
    }
}

exports.UserModel = mongoose.model('users', {
    username: String,
    password: String,
    info: {
        bio: String,
        nickname: String,
        address: String,
        link: String,
        twitter: String,
    },
    /**
     * @type { Array<RepoItem> }
     */
    repos: Array,
})